<template>
    <div class="comment">
    <!-- 表格 -->
       <el-table :data="comment">
           <el-table-column prop="id" label="编号" width="80"></el-table-column>
           <el-table-column prop="score" label="分数"></el-table-column>
           <el-table-column prop="content" label="评论"></el-table-column>
           <el-table-column prop="commentTime" label="评论时间"></el-table-column>
           <el-table-column prop="orderId" label="用户姓名"></el-table-column>
           <el-table-column prop="parentId" label="员工姓名"></el-table-column>
           <el-table-column label="操作" fixed="right">
            <template slot-scope="scope">   
               <el-button type="primary" size="small" @click="shenhe(scope.row)">审核</el-button>
            </template>
           </el-table-column>      
       </el-table>
    <!-- /表格 -->
    <!-- 模态框 -->
    <el-dialog title="评论审核" :visible.sync="visible">
        <p>用户姓名：{{this.comm.orderId}}</p>
        <p>评论：{{this.comm.content}}</p>
     <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="submit">确认</el-button>
           <el-button type="danger" @click="refuse">删除</el-button>
    
       </div>
        </el-dialog>
    <!-- /模态框 -->    
    </div>
</template>
<script>
import{ get,post } from "@/utils/request";
export default {
    data(){
        return{
            visible:false,
            comment:[],
            comm:[]
        }
    },
    created(){
        this.loadComment();
    
        

    },
    methods:{
        loadComment(){
            let url = "http://121.199.43.121:8090/comment/findAll";
            get(url).then(response=>{
                this.comment=response.data;
            })
        },
        shenhe(row){
            this.comm = row;
            this.visible = true;
        },
        refuse(row){
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
            type: 'warning'
        }).then(() => {
          let url = "http://121.199.43.121:8090/comment/deleteById";
          get(url,{id:row.id}).then((response) =>{
            // 提示
            this.$message({type:'success',message:response.message})
            // 刷新数据
            this.loadComment();
          })
        })
        },
        submit(){
                this.visible = false;
        }
    }
    
}
</script>